package com.jetbrains.edu.uiOnboarding.transitions

import com.intellij.ui.awt.RelativePoint
import com.jetbrains.edu.uiOnboarding.EduUiOnboardingAnimation
import com.jetbrains.edu.uiOnboarding.EduUiOnboardingAnimationData
import com.jetbrains.edu.uiOnboarding.EduUiOnboardingAnimationData.Companion.JUMP_DURATION
import com.jetbrains.edu.uiOnboarding.EduUiOnboardingAnimationStep
import com.jetbrains.edu.uiOnboarding.TransitionType
import com.jetbrains.edu.uiOnboarding.ZhabaImage
import java.awt.Point
import javax.swing.JFrame

class FinalJumpDown(image: ZhabaImage, data: EduUiOnboardingAnimationData, startPoint: RelativePoint, frame: JFrame) : EduUiOnboardingAnimation {

  override val steps: List<EduUiOnboardingAnimationStep> = listOf(
    EduUiOnboardingAnimationStep(image, startPoint, startPoint, 1_000),
    EduUiOnboardingAnimationStep(data.jumpDown, startPoint, pointAtTheBottom(data, frame, startPoint), JUMP_DURATION, TransitionType.EASE_OUT),
  )

  private fun pointAtTheBottom(data: EduUiOnboardingAnimationData, frame: JFrame, startPoint: RelativePoint) = RelativePoint(
    frame,
    Point(startPoint.getPointOn(frame).point.x, frame.height + data.jumpDown.screenSize.height + EduUiOnboardingAnimationData.zhabaScale(40))
  )
}